package com.daedalus.Gui.login;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;


public class gui extends JPanel implements ActionListener{

	JLabel emri;
	JLabel pass;
	JTextField user;
	JPasswordField passw;
	JTextArea area;
	JButton button;
	
	public gui(){
		setLayout(null);
        setSize(600,700);

		emri=new JLabel("User Name");
		emri.setSize(150, 30);
		emri.setLocation(100, 10);
        add(emri);

        pass=new JLabel("password");
		pass.setSize(150, 30);
		pass.setLocation(100, 50);
		
		user=new JTextField("user");
        user.setSize(new Dimension(150,30));
        user.setLocation(250,10);

		passw=new JPasswordField();
		passw.setSize(150,30);
		passw.setLocation(250, 50);
		


		button=new JButton("Insert");
		button.setSize(150, 40);
		button.setLocation(150, 450);

        area=new JTextArea();
        area.setSize(500, 300);
        area.setLocation(0, 0);

		JScrollPane paneliMeLevizje=new JScrollPane(area);
        paneliMeLevizje.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
        paneliMeLevizje.setSize(500, 300);
        paneliMeLevizje.setLocation(0, 130);

		add(button);
		add(pass);
		add(user);
		add(passw);
		add(paneliMeLevizje);

        button.addActionListener(this);

	}
	

    @Override
    public void actionPerformed(ActionEvent e) {
        if(e.getSource()==button){
            String s=String.format("Username: %s  Password: %s ", user.getText(),new String(passw.getPassword()));
            area.setText(s);
        }
    }

    public static void main(String[] args){
        JFrame frame = new JFrame("Login");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(600,600);
        frame.getContentPane().add(new gui());
        frame.setVisible(true);
    }
}
